#include "lifeLampsControl.h"
#include "easylogging++.h"
#ifndef InitEASYLOG
#define InitEASYLOG
    INITIALIZE_EASYLOGGINGPP //日志功能初始化、静态变量初始化，所以必须放在主函数之外
#endif
//RecordLogToFile RLog;//必须先打开日志记录系统、这个是独立的 、生成对象就会初始化该系统
el::Logger* DataLogger = el::Loggers::getLogger("default");
// 设置日志系统
static void SetEasyLoggingConf(void)
{
    // 使用默认配置  
    el::Configurations myLoggingConf;  
    myLoggingConf.setToDefault();
    myLoggingConf.setGlobally(el::ConfigurationType::ToFile, "true");
    myLoggingConf.setGlobally(el::ConfigurationType::PerformanceTracking, "false");
    myLoggingConf.set(el::Level::Trace, el::ConfigurationType::Enabled, "false");
    myLoggingConf.set(el::Level::Debug, el::ConfigurationType::Filename, "dataLog/myLog_%datetime{%Y%M%d_%H%m%s_%g}_debug.log");
    myLoggingConf.set(el::Level::Error, el::ConfigurationType::Filename, "dataLog/myLog_%datetime{%Y%M%d_%H%m%s_%g}_error.log");
    myLoggingConf.set(el::Level::Fatal, el::ConfigurationType::Enabled, "false");//禁用
    myLoggingConf.set(el::Level::Warning, el::ConfigurationType::Enabled, "false");//禁用
    // myLoggingConf.set(el::Level::Warning, el::ConfigurationType::Filename, "dataLog/myLog_%datetime{%Y%M%d_%H%m%s_%g}_warning.log");
    myLoggingConf.set(el::Level::Info, el::ConfigurationType::Filename, "dataLog/myLog_%datetime{%Y%M%d_%H%m%s_%g}_info.log");
    myLoggingConf.set(el::Level::Verbose, el::ConfigurationType::Enabled, "false");//禁用
    el::Loggers::reconfigureAllLoggers(myLoggingConf);
	LOG(DEBUG)   << "***** debug log  *****";
	LOG(ERROR)   << "***** error log  *****";
	LOG(INFO)    << "***** info log  *****";
}

int main(int argc, char **argv){
    LifeLampsControl LLC;
    SetEasyLoggingConf();//初始化日志配置
    LLC.init(12,0,5, ws2812b::PI_Zero_2W);
	while(1)
    {
        LLC.testDemo();
        delay(8000);//等30s
    }
    // ws2812b * lifeLamps = new ws2812b(5); // 新建ws2812b的控制对象
    // lifeLamps->initHardware(12, 0); // 初始化
    // lifeLamps->clearLEDBuffer(); //所有的led灯全部置零
    // int now = 0;
    // for(;;){
	// 	//RGB Blink.
    //     for(int i = 0; i < 5; i++)
    //     {
    //         if (now == i)
    //         {
    //             lifeLamps->setPixelColor(i, 125, 0, 0);
    //         }
    //         else lifeLamps->setPixelColor(i, 0, 0, 0);
    //     }
    //     if(now++ == 5)
    //     now = 0;
    //     lifeLamps->show();
    //     usleep(1000*1000);
    // }
    return 0;
}
